﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FortuneHeavenCommon.DataMap;
using System.Data.SqlClient;

namespace FortuneHeavan.Game.DAL
{
    public class RecordUserEnterDAL : TreasureDBBase
    {
        public List<RecordUserEnter> GetUserEnterRecord(int userid)
        {
            string sql = "Select * from RecordUserEnter where UserID =@UserID";
            List<RecordUserEnter> content = Query<RecordUserEnter>(sql, new SqlParameter("@UserID", userid));
            return content;
        }

        public List<RecordUserEnter> GetUserEnterRecordList(int page, int size, int userid)
        {
            string sql = @"select * from (
select A.*,B.KindName
,ROW_NUMBER() OVER(ORDER BY A.EnterTime DESC) ROW 
from RecordUserEnter A inner join QPServerInfoDB.dbo.GameKindItem B on A.KindID= B.KindID  where  A.UserID =@UserID) FF
 WHERE FF.ROW BETWEEN  @p1 AND @p2"; ;
            List<RecordUserEnter> list = Query<RecordUserEnter>(sql, new SqlParameter("@UserID", userid), new SqlParameter("@p1", size * (page - 1) + 1), new SqlParameter("@p2", size * page));
            return list;
        }
        public int GetTotalSize(int userid)
        {
            string sql = @"select count(A.UserID) from RecordUserEnter A inner join QPServerInfoDB.dbo.GameKindItem B on A.KindID= B.KindID  where  A.UserID =@UserID";
            return RunSQL(sql, new SqlParameter("@UserID", userid));
        }
    }
}
